package com.zhoug.common3.utils.bundle;

import android.os.Bundle;
import android.os.Parcelable;

import java.io.Serializable;

import androidx.annotation.NonNull;

/**
 * @Author 35574
 * @Date 2022/3/9
 * @Description
 */
public class BundleUtils {

    public static Bundle put(@NonNull Bundle bundle, String key, Object value) {
        if (value instanceof Integer) {
            bundle.putInt(key, (Integer) value);
        }else  if (value instanceof Short) {
            bundle.putShort(key, (Short) value);
        }else  if (value instanceof Long) {
            bundle.putLong(key, (Long) value);
        } else if (value instanceof Float) {
            bundle.putFloat(key, (Float) value);
        } else if (value instanceof Double) {
            bundle.putDouble(key, (Double) value);
        }else if (value instanceof String) {
            bundle.putString(key, (String) value);
        }else if (value instanceof Boolean) {
            bundle.putBoolean(key, (Boolean) value);
        }else if (value instanceof Serializable) {
            bundle.putSerializable(key, (Serializable) value);
        }else if (value instanceof Parcelable) {
            bundle.putParcelable(key, (Parcelable) value);
        }
        return bundle;
    }


}
